package chepter04.d4_3;
abstract class Soundable{
    public abstract void makeSound();
    public abstract void adjustVolume(int volume);

}
class Radio extends Soundable{
    @Override
    public void makeSound(){
        System.out.println("收音机发出的声音");
    }
    @Override
    public void adjustVolume(int volume){
        System.out.println("调整收音机音量为："+volume);
    }

}
class MobilePhone extends Soundable{
    @Override
    public void makeSound(){
        System.out.printle("手机发出的声音");
    }
    @Override
    public void adjustVolume(int volume){
        System.out.println("调整手机音量为："+volume);
    }
}
public class Tsound {
    public static void main(String[] args) {
        Soundable soundable = null;
        Scanner scanner = new Soundable(System.in);
        System.out.println("请选择设备(1.收音机 2.随身听 3.手机):");
        int choice = scanner.nextlnt();
        switch (choice){
            case 1:
                soundable = new Radio();
            break;
            case 2:
                soundable = new Walkman();
                break;
            case 3:
                soundable = new MobilePhone();
                break;
            default:
                System.out.println("无效的选择");
                return;
        }
        soundable.makeSound();
        System.out.println("请输入音量：");
        int volume = scanner.nextlnt();
        soundable.adjustVolume(volume);
        //示例
    }
}
